Skip to content

CS-10677: Add boxel run-command CLI command#4421

Open
FadhlanR wants to merge 3 commits intomainfrom
cs-10677-add-boxel-run-command
Open

CS-10677: Add boxel run-command CLI command#4421
FadhlanR wants to merge 3 commits intomainfrom
cs-10677-add-boxel-run-command

Conversation

@FadhlanR
Copy link
Copy Markdown
Contributor

Summary

  • Add top-level boxel run-command <specifier> --realm <url> [--input '{}'] [--json] CLI command that executes host commands on the realm server via the /_run-command endpoint
  • Export a programmatic runCommand() function for use by other CLI commands
  • Unit tests covering success, error status, HTTP failures, network failures, missing profile, trailing slash handling, and malformed responses

Test plan

  • pnpm vitest run in packages/boxel-cli passes all new tests
  • Manual test with a running realm server: boxel run-command @cardstack/boxel-host/commands/get-card-type-schema/default --realm <url> --input '{"cardURL": "..."}'

🤖 Generated with Claude Code

FadhlanR and others added 2 commits April 16, 2026 17:53
Add a top-level `boxel run-command` command that executes host commands
on the realm server via the `/_run-command` endpoint. Includes a
programmatic `runCommand()` API and unit tests covering success, error,
HTTP failure, network failure, missing profile, and malformed responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@FadhlanR FadhlanR marked this pull request as ready for review April 16, 2026 12:24
@FadhlanR FadhlanR requested a review from a team April 16, 2026 12:24
@habdelra habdelra requested a review from Copilot April 16, 2026 14:06
@habdelra
Copy link
Copy Markdown
Contributor

so the important thing here is that this command needs to use the realm server token (vs the realm specific token). my LLM is always getting these 2 types of tokens confused. how are you managing the server token?


let response: Response;
try {
response = await pm.authedRealmServerFetch(url, {
Copy link
Copy Markdown
Contributor

@habdelra habdelra Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this know to use the server token and not a realm specific token? and is there a test that can prove that by making sure these two tokens are actually different in the real realm test. (i find that the LLM gets confused here and tries to make these 2 the same token all the time)

Copy link
Copy Markdown
Contributor Author

@FadhlanR FadhlanR Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that the LLM itself determines which tokens should be used? If so, it is not needed, because we store the realm server token and realm-specific tokens in the profile.json file, since they are generated after the LLM executes the boxel-profile command. Additionally, there are two fetch functions in the Boxel CLI, authedRealmServerFetch and authedRealmFetch, which are used by the commands to retrieve data using one of those two tokens, depending on the command.

Copy link
Copy Markdown
Contributor

@habdelra habdelra Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. i mean the LLM that you are using to help you code this feature up. (assuming claude code). its really bad at telling the difference between server tokens and realm tokens. for me it's introduced dozens of bugs around this that have wasted many hours for me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see--since you are using authedRealmServerFetch that is how we know to chose the correct token 👍

Comment thread docs/cs-10677-run-command-plan.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new boxel run-command top-level CLI command (plus a reusable runCommand() helper) to execute host commands on a realm server via the /_run-command endpoint, with accompanying integration coverage and a short implementation plan doc.

Changes:

  • Introduces runCommand() and registerRunCommand() to POST JSON:API payloads to /_run-command using ProfileManager.authedRealmServerFetch.
  • Registers the new run-command subcommand in the CLI entrypoint.
  • Adds an integration test that spins up a test realm server and validates request shape + basic success path.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/boxel-cli/src/commands/run-command.ts Implements the new CLI command + exported helper that calls the realm-server /_run-command endpoint
packages/boxel-cli/src/index.ts Registers the new command with the top-level Commander program
packages/boxel-cli/tests/integration/run-command.test.ts Adds integration coverage for successful execution and request/URL shaping
docs/cs-10677-run-command-plan.md Adds a short implementation plan for the feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/boxel-cli/src/commands/run-command.ts
Comment thread packages/boxel-cli/src/commands/run-command.ts
Comment thread docs/cs-10677-run-command-plan.md Outdated
Comment thread packages/boxel-cli/src/commands/run-command.ts
Comment thread packages/boxel-cli/src/commands/run-command.ts Outdated
- Remove plan doc from repo (reviewer feedback)
- Type Commander opts with RunCommandCliOptions interface
- Validate --input is a plain JSON object (reject arrays/nulls/primitives)
- Wrap response.json() in try/catch for malformed response handling
- Add error-handling tests (non-2xx, invalid JSON, fetch throw)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@FadhlanR FadhlanR requested a review from habdelra April 17, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants